package net.minecraft.src;

import java.util.HashMap;
import java.util.Map;
import net.minecraft.src.forge.*;
import tehMod.*;

public class mod_TehMod extends BaseMod {

	public static final BlockVillageChest VillageChest = new BlockVillageChest(254);
	public static final BlockBanner bannerBlock = new BlockBanner(253);
	public static final ItemBanner bannerItem = new ItemBanner(190);
	
	public static final String blockTexture = "/tehmod/terrain.png";
	public static final String itemTexture = "/tehmod/items.png";
	
	public static int chestModelID;
	public static int bannerModelID;
	
	public static final Map<String, String> textures = new HashMap<String, String>() {{
		   put("VillageChest", "/tehmod/chest.png");
		   put("VillageChestLarge", "/tehmod/largechest.png");
		   put("Banner", "/tehmod/banner.png");
	}};
	
	@Override
	public String getVersion() {
		return "1.1";
	}

	@Override
	public void load() {
		initResources();
		initEntities();
		initRecipes();
	}
	
	public void AddRenderer(Map map) {
		map.put(EntityTehVillager.class, new RenderTehVillager());
		
	}
	
	@Override
	public void RenderInvBlock(RenderBlocks renderblocks, Block block, int metaData, int modelID) {
		if (modelID == chestModelID) {
			Tessellator.instance.setColorOpaque_F(1, 1, 1);
			TileEntityRenderer.instance.renderTileEntityAt(new TileEntityVillageChest(), 0.0D, 0.0D, 0.0D, 0.0F);
			Tessellator.instance.setColorOpaque_F(1, 1, 1);
		}
	}
	
	private void initResources() {
		chestModelID = ModLoader.getUniqueBlockModelID(this, true);
		bannerModelID = ModLoader.getUniqueBlockModelID(this, true);
		
		System.out.println("CHEST MODEL ID: " + chestModelID);
		MinecraftForgeClient.preloadTexture(itemTexture);
		MinecraftForgeClient.preloadTexture(blockTexture);
		for (Map.Entry<String, String> entry : textures.entrySet()) {
			MinecraftForgeClient.preloadTexture(entry.getValue());
		}
	}
	
	private void initEntities() {
		ModLoader.RegisterEntityID(EntityTehVillager.class, "TehVillager", ModLoader.getUniqueEntityId());
		//ModLoader.RegisterTileEntity(TileEntityBanner, "Banner", TileEntityBannerRenderer);
	}
	
	private void initRecipes() {
		ModLoader.AddRecipe(new ItemStack(Item.bed, 1), new Object[] {
			"S",
			'S', Item.stick
		});
		ModLoader.AddRecipe(new ItemStack(Item.paper, 64), new Object[] {
			"P",
			'P', Block.planks
		});
	}

}
